package org.ph.share.lock.test.thread;

import lombok.extern.slf4j.Slf4j;

/**
 * Thread 测试类
 *
 * @author Hush.
 * @since 2023/5/15 9:53
 */
@Slf4j
public class ThreadTest1 {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread("t1") {
            @Override
            public void run() {
                log.info("test interrupt 1");
                try {
                    log.info("test interrupt start");
                    Thread.sleep(5000);
                    log.info("test interrupt sleep-interrupt");
                } catch (InterruptedException e) {
                    log.error("test interrupt catch ", e);
                    throw new RuntimeException(e);
                } finally {
                    log.info("test interrupt finally ");
                }
                log.info("test interrupt run");

            }
        };
        thread.start();
        Thread.sleep(200);
        // 中断
        thread.interrupt();
    }
}
